/*
 * @lc app=leetcode.cn id=844 lang=javascript
 *
 * [844] 比较含退格的字符串
 */

// @lc code=start
function dealString(str) {
    const stack = [];
    for(const ch of str) {
        ch === '#' ? stack.pop() : stack.push(ch);
    }
    return stack.join('');
}

/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var backspaceCompare = function(s, t) {
    return dealString(s) === dealString(t);
};
// @lc code=end

